package com.mc.moring.main.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mc.moring.R;
import com.mc.moring.bean.MyLoanListBean;
import com.mc.moring.util.LoanState;
import com.mc.moring.util.StringUtils;
import com.mc.moring.util.TimeUtils;
import com.mc.moring.util.ext.StringExt;


public class MyLoanDetailsAdapter extends BaseQuickAdapter<MyLoanListBean.loanListBean, BaseViewHolder> {

    private TextView text5;

    public MyLoanDetailsAdapter() {
        super(R.layout.item_my_loan_details);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyLoanListBean.loanListBean item) {
        helper.setText(R.id.tv_position, "Cuota "+item.getPaymentIndex());
        helper.setText(R.id.tv_1, item.getLoanId());
        helper.setText(R.id.tv_2, item.getMobile());
        helper.setText(R.id.tv_3, LoanState.INSTANCE.getText(Integer.parseInt(item.getStatus())));
        if (item.getCreateTime() != null) {//2002 3002 3003 4001 2004
            switch (item.getStatus()){
                case "2002":
                case "3002":
                case "3003":
                case "4001":
                case "2004":
                    helper.setText(R.id.tv_4, TimeUtils.date2FormatDetailDate(item.getCreateTime()));
                    break;
                default:
                    helper.setText(R.id.tv_4, "");
                    break;
            }
        }
        if (item.getLendOutTime() != null) {
            helper.setText(R.id.tv_5, TimeUtils.date2FormatDetailDate(item.getLendOutTime()));
            if ( item.getLendOutTime().equals("0") || item.getLendOutTime().equals("")){
                helper.setGone(R.id.Tiempo_Time, false);
            }
        }

        helper.setText(R.id.tv_6, StringUtils.keepLastFourDigits(item.getBankAccountNo()));
        if (!TextUtils.isEmpty(item.getApplyAmount())) {
//            helper.setText(R.id.tv_7, "$"+
//                    StringUtils.formatNumberWithCommas(String.valueOf(Math.round(Double.parseDouble(item.getApplyAmount())))));
            helper.setText(R.id.tv_7, "$"+ StringExt.INSTANCE.extFormatMoney(item.getApplyAmount()));
        }

        helper.setText(R.id.tv_8, item.getLimitDays());
        helper.setText(R.id.tv_9, TimeUtils.date2FormatDate(item.getDueDate()));
        if (item.getPostLoanFee() != null) {
//            helper.setText(R.id.tv_10, "$"+
//                    StringUtils.formatNumberWithCommas(String.valueOf(item.getPostLoanFee()).toString()));
            helper.setText(R.id.tv_10, "$"+ StringExt.INSTANCE.extFormatMoney(item.getPostLoanFee()));
        }
        if (item.getAmount() != null) {
//            helper.setText(R.id.tv_11, "$"+
//                    StringUtils.formatNumberWithCommas(String.valueOf(item.getAmount()).toString()));
            helper.setText(R.id.tv_11, "$"+ StringExt.INSTANCE.extFormatMoney(item.getAmount()));
        }
        if (item.getInterestAmount() != null) {
//            helper.setText(R.id.tv_12, "$"+StringUtils.formatNumberWithCommas(item.getInterestAmount()));
            helper.setText(R.id.tv_12, "$"+StringExt.INSTANCE.extFormatMoney(item.getInterestAmount()));

        }
        if (item.getSurplusPenaltyAmount() != null) {
//            helper.setText(R.id.tv_13, "$"+StringUtils.formatNumberWithCommas(item.getSurplusPenaltyAmount()));
            helper.setText(R.id.tv_13, "$"+StringExt.INSTANCE.extFormatMoney(item.getSurplusPenaltyAmount()));
        }
        if (item.getPaidPenaltyAmount() != null) {
//            helper.setText(R.id.tv_14, "$"+StringUtils.formatNumberWithCommas(item.getPaidPenaltyAmount()));
            helper.setText(R.id.tv_14, "$"+StringExt.INSTANCE.extFormatMoney(item.getPaidPenaltyAmount()));
        }

    }

}
